1 00:00:00,000 --> 00:00:13,560 This is Hacker Public Radio episode 4,025 for Friday the 5th of January 2024. 2 00:00:13,560 --> 00:00:17,600 Today's show is entitled, Testing V-Language. 3 00:00:17,600 --> 00:00:20,240 It is part of the series languages. 4 00:00:20,240 --> 00:00:25,040 It is hosted by Celeste and is about 17 minutes long. 5 00:00:25,040 --> 00:00:27,640 It carries a clean flag. 6 00:00:27,640 --> 00:00:32,520 The summary is I tried the New Experimental Programming Language. 7 00:00:32,520 --> 00:00:41,720 Today's show is licensed under a Creative Commons non-commercial license. 8 00:00:41,720 --> 00:00:46,000 Hello everyone and welcome to this new episode of Hacker Public Radio. 9 00:00:46,000 --> 00:00:52,400 Today we will dive into an Experimental and New Programming Language called the V Programming 10 00:00:52,400 --> 00:00:54,200 Language. 11 00:00:54,200 --> 00:01:04,880 It has been created by Guy from Netherlands, Alexander Medvednikov. 12 00:01:04,880 --> 00:01:11,400 It's still experimental, but the foundations are really cool. 13 00:01:11,400 --> 00:01:18,520 And I want to explain, I tried it for some days, what I think it's heading in a greater 14 00:01:18,520 --> 00:01:26,680 direction and which parts instead are heading to a bad direction. 15 00:01:26,680 --> 00:01:30,680 I fear some of them. 16 00:01:30,680 --> 00:01:34,640 So let's start with the great benefits. 17 00:01:34,640 --> 00:01:45,000 Strong static typing, it's not a functional language, it's not a really low level 18 00:01:45,080 --> 00:01:53,160 language, it feels lighter, it feels like go, it's quite similar, really similar for the 19 00:01:53,160 --> 00:01:59,920 syntax, but it has very, very strong static typing, very strong and that's good. 20 00:01:59,920 --> 00:02:12,240 It has, it borrow some of the concepts of some types, which means you can, and pattern 21 00:02:12,240 --> 00:02:18,800 matching, which has one of the great features of drafts that have been borrowed by other 22 00:02:18,800 --> 00:02:25,600 research-level languages and put into a more usable production-ready language. 23 00:02:25,600 --> 00:02:28,920 And V-language is also taking this. 24 00:02:28,920 --> 00:02:38,840 So you have option and result types for to mark functions and return types and values 25 00:02:38,840 --> 00:02:47,160 that can be either empty or can contain something or can, like some other stuff like 26 00:02:47,160 --> 00:02:52,720 file access, which can have input output errors. 27 00:02:52,720 --> 00:02:59,000 So you have to make sure you handle the errors state. 28 00:02:59,000 --> 00:03:06,200 If something went wrong, you have to still the program what to do every time. 29 00:03:06,200 --> 00:03:13,200 This is something that gets really overlooked in C and in many other languages. 30 00:03:13,200 --> 00:03:22,680 You, the function says, hey, if this function returns me, I use one or a specific value, 31 00:03:22,680 --> 00:03:29,680 it means that there was an error and make sure to check the return code, but it's so 32 00:03:29,680 --> 00:03:35,680 verbose that no one checks every return code. 33 00:03:35,680 --> 00:03:40,560 And it's really easy even if you want to try to check every return code. 34 00:03:40,560 --> 00:03:47,080 It's really easy to forget about some of them. 35 00:03:47,080 --> 00:03:57,680 By instead by having the result type, it means that if you want to use the value that was 36 00:03:57,680 --> 00:04:08,760 returned by the function, for example, on file read access, you have to tell the compiler what 37 00:04:08,760 --> 00:04:13,760 to do if there was an error. 38 00:04:13,760 --> 00:04:18,920 If it's okay, you can use the value, but you have to tell explicitly what to do if there 39 00:04:18,920 --> 00:04:20,200 is an error. 40 00:04:20,200 --> 00:04:25,680 And maybe the solution is to crash, but you have to tell the compiler if there is an error 41 00:04:25,680 --> 00:04:27,360 here, crash. 42 00:04:27,360 --> 00:04:37,360 If you don't tell the compiler, it won't compile and that's really great. 43 00:04:37,360 --> 00:04:45,960 So it takes many parts from a good type system and heavily inspired from the last type 44 00:04:45,960 --> 00:04:52,880 system and so I really like that part. 45 00:04:52,880 --> 00:05:01,800 But with an additional benefit, it's automatic memory management. 46 00:05:01,800 --> 00:05:05,640 That's really, really great for many tasks. 47 00:05:05,640 --> 00:05:14,160 Not for low level stuff, for low level stuff, obviously you won't find a greater control 48 00:05:14,160 --> 00:05:28,680 over memory, but sometimes you won't really want automatic memory management. 49 00:05:28,680 --> 00:05:37,600 That's something you usually get from higher level languages like Python or Java. 50 00:05:37,600 --> 00:05:47,360 But they run in an interpreter or in a Java virtual machine, we are other very big 51 00:05:47,360 --> 00:05:56,200 program, just to run your code, you cannot just have a simple executable like you 52 00:05:56,200 --> 00:06:03,040 would produce in CNN and run it and have automatic memory management on that instead. 53 00:06:03,040 --> 00:06:12,040 And that's something VIT achieves, that's really useful. 54 00:06:12,040 --> 00:06:24,400 You get a really small compile binary, because the compiler intermediate user uses C, it 55 00:06:24,400 --> 00:06:29,720 turns V code to C code and then compiles the C code. 56 00:06:29,720 --> 00:06:36,720 So you get a really small executable, you get for free all the platforms support that 57 00:06:36,720 --> 00:06:45,680 C compilers have had since C exists, you get all of that for free and plus, as you 58 00:06:45,680 --> 00:06:54,600 I said, you get memory management, memory allocation, which is really great for some tasks. 59 00:06:54,600 --> 00:07:05,280 For example, the rest solves that by using the borrowed tracker and the move semantics. 60 00:07:05,280 --> 00:07:16,160 I'm a way of keeping track that only variable, only one variable at a time is responsible 61 00:07:16,160 --> 00:07:22,760 to be the owner of some value and it is responsible to clean it. 62 00:07:22,760 --> 00:07:34,200 And in order to do that, there are, the rest compiler is a lot stricter in what you can do 63 00:07:34,200 --> 00:07:40,520 at what you cannot do, what memory can you access at what you can if the rest compiler 64 00:07:40,520 --> 00:07:49,960 can make sure that a code you are doing to a variable is valid and it's leading to 65 00:07:49,960 --> 00:08:00,360 a correct memory address, it won't compile. 66 00:08:00,360 --> 00:08:05,600 So yeah, you have to find the borrowed tracker and find the compiler many times depending 67 00:08:05,600 --> 00:08:07,600 on what you're doing. 68 00:08:07,600 --> 00:08:18,960 One of the fields where you feel the problems of the rest approach the most is user interfaces. 69 00:08:18,960 --> 00:08:30,440 If you're building a graphical user interface, it's hard, it's hard because you have 70 00:08:30,440 --> 00:08:36,360 many interconnected parts that need to share some variables. 71 00:08:36,360 --> 00:08:43,680 So you have a part with event listeners, a part with the components you want to throw 72 00:08:43,680 --> 00:08:52,320 and then event listeners attach to the components, to the button for example, so that 73 00:08:52,320 --> 00:08:55,560 it activates when you click on it. 74 00:08:55,560 --> 00:09:09,360 Then the event listener, in turn, should call and modify other variables, but the scope 75 00:09:09,360 --> 00:09:18,360 of the event listeners is different from the scope of the component, it has been declared 76 00:09:18,360 --> 00:09:29,720 into, it can live more, it can live less, the variables it's using also can live more 77 00:09:29,720 --> 00:09:37,200 or less than its lifetime, it's really a hard problem if you don't have a garbage collector, 78 00:09:37,200 --> 00:09:39,440 it's really a hard problem. 79 00:09:39,440 --> 00:09:47,600 So for graphical user interfaces, a garbage collector is really useful and I like that 80 00:09:47,600 --> 00:09:59,200 we have both start strong static typing, both garbage collection and both it produces 81 00:09:59,200 --> 00:10:07,160 a very small binary by going through C, it's really useful, it haven't found any 82 00:10:07,160 --> 00:10:16,560 things similar so far, the most similar one is Scala, but it needs the Java virtual machine 83 00:10:16,560 --> 00:10:29,400 which is an elephant for its sides and I don't want that, yeah now we talk about the last 84 00:10:29,400 --> 00:10:36,160 advantage of the V-language that I liked and then we will go into these advantages and 85 00:10:36,160 --> 00:10:39,120 problems of it. 86 00:10:39,120 --> 00:10:51,560 So another cool thing, compile time reflection, reflection means being able to declare a 87 00:10:51,560 --> 00:11:03,920 struct and then being able to iterate over the struct field and types, so you can iterate 88 00:11:03,920 --> 00:11:11,320 in your code and say, hey, if this for each field of the struct, if the field type 89 00:11:11,320 --> 00:11:19,600 is an integer then inject this code, if the field type is a string inject this code 90 00:11:19,600 --> 00:11:30,360 instead and in some languages like, go for example, you can access that data at your 91 00:11:30,360 --> 00:11:40,440 time, but here you can access it at compile time, so the only code that gets generated 92 00:11:40,440 --> 00:11:48,600 is the code that matches those for cycle and if conditions of types and field names you 93 00:11:48,600 --> 00:11:56,680 wrote, so for example if you want to parse a query string and you want to parse the query 94 00:11:56,720 --> 00:12:11,400 string into a struct, you need to know and inject into your code what are the types of the 95 00:12:11,400 --> 00:12:20,280 struct fields, so you can convert each value from the query string which is will be a string 96 00:12:20,280 --> 00:12:27,880 value to the correct type in the field in each field. 97 00:12:27,880 --> 00:12:35,880 To do that you can write a specialized code for each struct, so for extract you manually 98 00:12:35,880 --> 00:12:46,240 write the parsing, that's one approach, but in the you can make a generic function that works 99 00:12:46,240 --> 00:12:57,480 on every struct type and at compile time it takes the type, it looks at what the struct 100 00:12:57,480 --> 00:13:06,640 fields are and what are each their types and it generates the code for each field to parse 101 00:13:06,640 --> 00:13:13,120 the query string, you can make that, it feels a lot like Rust macros, Rust, there are 102 00:13:13,280 --> 00:13:22,160 macros, you can achieve something similar, but Rust there are macros of both more powerful 103 00:13:22,160 --> 00:13:33,840 but also very very hard to write, I tried to write one for a project and it was really really 104 00:13:33,920 --> 00:13:44,720 hard time, while compile time refraction as in v suits more most cases without problems, 105 00:13:48,720 --> 00:13:58,080 so let's go to the bad part, the dark part, first it's still in beta version, it's a language 106 00:13:58,160 --> 00:14:13,680 from 2019 and it's at the 0.4 version and still a long time to reach the stable version, 107 00:14:14,480 --> 00:14:22,800 things may change, things are partially broken, the compiler works decently, but works decently 108 00:14:22,800 --> 00:14:35,840 but I found some compiler bugs here and there, but works overall, certainly you don't want to 109 00:14:35,840 --> 00:14:46,960 build anything for production now using v, the second problem is that it wants to be really really 110 00:14:47,920 --> 00:14:56,080 clean, but they are adding too many features, they are adding database object relational mapping 111 00:14:56,080 --> 00:15:04,160 into the language, really cool but maybe too much, they are adding a functionality to write 112 00:15:04,160 --> 00:15:15,040 GPU shaders in v language, yeah cool but yeah, maybe too much, I would really prefer if they 113 00:15:15,120 --> 00:15:30,000 stabilize the strong core points of the v language that I highlighted and refind them instead of adding 114 00:15:30,800 --> 00:15:43,040 too many features and complicating the language before even how can I say? 115 00:15:46,000 --> 00:15:51,360 before adding more stuff instead of adding more stuff it's better to refine the core, 116 00:15:54,480 --> 00:16:01,200 overall it has been a really cool experience, I don't get usually excited for 117 00:16:04,400 --> 00:16:12,160 new programming languages, I want to use one or two programming languages that work and then 118 00:16:12,800 --> 00:16:22,480 are reliable and solid, but yeah it seems like a good combination of ideas, 119 00:16:24,640 --> 00:16:31,920 good static typing, small sites binary and compiling to an actual executable, 120 00:16:31,920 --> 00:16:38,400 no job of retone machine and then the same time immutability by default pattern matching 121 00:16:38,400 --> 00:16:45,520 result types compiling reflection and garbage collection, all of at the same time, 122 00:16:46,960 --> 00:16:51,600 I'm really interested in seeing how it goes and what it will 123 00:16:55,360 --> 00:17:03,760 reach, I noticed now that you can also donate to the author if you want 124 00:17:03,760 --> 00:17:15,920 and yeah but but first I would encourage you to try it and let me know in the comments 125 00:17:17,200 --> 00:17:24,800 how it felt, was it interesting, was it functional, did you prefer some other types of programming 126 00:17:24,880 --> 00:17:32,320 languages or and why, thank you for listening and see you next time 127 00:17:36,080 --> 00:17:40,960 you have been listening to Hacker Public Radio at Hacker Public Radio does work, 128 00:17:40,960 --> 00:17:46,560 today's show was contributed by a HBR this night like yourself, if you ever thought of a 129 00:17:46,560 --> 00:17:53,120 recording podcast, click on our contributely to find out how easy it means, posting 130 00:17:53,120 --> 00:18:01,200 for HBR has been kindly provided by an onsthost.com, the internet archive and our synced.net 131 00:18:01,200 --> 00:18:06,160 on the satellite stages, today's show is released on our creative comments, 132 00:18:06,160 --> 00:18:13,520 attribution for going to international license